﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NEM;

namespace NEM.Windows_Forms
{
    public partial class frmApplicationSettings : Form
    {
        #region Private Variables / Constants
        #endregion

        #region Constructors
        public frmApplicationSettings()
        {
            InitializeComponent();
            _ApplicationSettings = Globals.ApplicationSettings;
            propertyGrid1.SelectedObject = _ApplicationSettings;

            this.ShowInTaskbar = false;
            this.TopMost = true;
        }
        #endregion

        #region Properties
        private ApplicationSettings _ApplicationSettings = null;
        [Category("New Settings")]
        [DisplayName("New Application Settings")]
        [Description("The new Application Settings.")]
        public ApplicationSettings NewApplicationSettings
        {
            get { return _ApplicationSettings; }
            set { _ApplicationSettings = value; }
        }
        #endregion

        #region Methods
        public bool ExportToFile(string pFullPathName)
        {
            bool lvResult = true;

            return lvResult;
        }

        public bool ImportFormFile(string pFullPathName)
        {
            bool lvResult = true;

            return lvResult;
        }

        #endregion

        #region Overrides
        public override string ToString()
        {
            return "Application Settings Form";
        }
        #endregion

        private void btnSave_Click(object sender, EventArgs e)
        {
            Globals.ApplicationSettings = _ApplicationSettings;
            if (Globals.SaveApplicationSettings(_ApplicationSettings.MainSaveType))
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("Failed to Save.");
            }
        }

        private void reloadSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Globals.LoadApplicationSettings(Globals.ApplicationSettings.MainSaveType);
            propertyGrid1.SelectedObject = Globals.ApplicationSettings;
        }
    }
}
